package com.coolingme.general;

/**
 * 迭代器模式测试
 *
 * @author wangyue
 * @date 2020-09-24 0:34
 */
public class Test {

    public static void main(String[] args) {
        ConcreteAggregate<Integer> aggregate = new ConcreteAggregate<>();

        aggregate.add(1);
        aggregate.add(2);
        aggregate.add(3);
        aggregate.add(4);
        aggregate.remove(3);
        aggregate.add(5);

        Iterator<Integer> iterator = aggregate.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }

    }

}
